package com.boge.parse;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import flex.messaging.io.SerializationContext;
import flex.messaging.io.amf.Amf3Input;
import flex.messaging.io.amf.Amf3Output;

/**
 * Amf3Stream管理
 * @author boge
 *
 */
public class Amf3Stream {

	private static SerializationContext context = new SerializationContext();
	
	/**
	 * 创建一个新的Amf3Output
	 * @param outputStream
	 * @return
	 */
	public static Amf3Output newAmf3Output(ByteArrayOutputStream outputStream) {
		Amf3Output output = new Amf3Output(context);
		output.setOutputStream(outputStream);
		return output;
	}
	
	/**
	 * 创建一个新的Amf3Output
	 * @return
	 * 
	 */
	public static Amf3Output newAmf3Output() {
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		Amf3Output output = new Amf3Output(context);
		output.setOutputStream(outputStream);
		return output;
	}
	
	/**
	 * 创建一个新的AmfInput
	 * @param inputStream
	 * @return
	 */
	public static Amf3Input newAmf3Input(ByteArrayInputStream inputStream) {
		Amf3Input input = new Amf3Input(context);
		input.setInputStream(inputStream);
		return input;
	}
	
	/**
	 * 创建一个新的AmfInput
	 * @return
	 * 
	 */
	public static Amf3Input newAmf3Input(byte[] buf) {
		ByteArrayInputStream inputStream = new ByteArrayInputStream(buf);
		Amf3Input input = new Amf3Input(context);
		input.setInputStream(inputStream);
		return input;
	}
	
}